﻿using project.B12.Model.BaseModel;
using project.B12.Model.Enums;
using project.B12.Model.Models;
using software.dll.user;
using System.Collections.ObjectModel;

namespace project.B12.IService
{
    public interface IUserService
    {
        #region 通用资源及功能
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        MessageModel Login(string? userName, string? password,bool Count);

        /// <summary>
        /// 获取配置文件用户
        /// </summary>
        /// <returns></returns>
        string? GetConfigUserName();

        /// <summary>
        /// 当前用户,软件启动后会更新为最后登录用户
        /// </summary>
        String UserName { get; }


        /// <summary>
        /// 当前已登录账户信息
        /// </summary>
        UserModel CurrentUser { get; set; }

        /// <summary>
        /// 初始化用户服务
        /// </summary>
        void Init();
        #endregion

        #region 用户清单
        /// <summary>
        /// 获取用户清单
        /// </summary>
        /// <returns></returns>
       (MessageModel,ObservableCollection<UserModel>) GetAllUsers();

        /// <summary>
        /// 重置用户清单
        /// </summary>
        /// <returns></returns>
        MessageModel ResetUsersList();

        /// <summary>
        /// 更改用户状态
        /// </summary>
        /// <param name="name"></param>
        MessageModel ChangeLockedState(UserModel name);

        /// <summary>
        /// 检查密码是否合规
        /// </summary>
        /// <param name="password"></param>
        /// <returns></returns>
        MessageModel CheckPassword(string password);

        /// <summary>
        /// 更新用户密码
        /// </summary>
        /// <param name="name"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        MessageModel UpdateUser(string name, string password);

        /// <summary>
        /// 更新账户过期时间
        /// </summary>
        /// <param name="name"></param>
        /// <param name="newUserExpirationTime"></param>
        /// <returns></returns>
        MessageModel UpdateExpirationTime(string name, ExpirationTimeEnum? newUserExpirationTime);

        /// <summary>
        /// 删除用户
        /// </summary>
        /// <param name="pUserName"></param>
        /// <returns></returns>
        MessageModel DeleteUser(string pUserName);

        /// <summary>
        /// 获取用户权限
        /// </summary>
        /// <param name="name"></param>
        /// <param name="rightEnum"></param>
        /// <returns></returns>
        bool GetUserRight(RightEnum rightEnum);
        #endregion

        #region 修改密码
        /// <summary>
        /// 修改密码
        /// </summary>
        /// <returns></returns>
        MessageModel ChangePassword(string name, string newPassword);
        #endregion

        #region 新增用户
        Dictionary<string, ExpirationTimeEnum> ExpirationTimeEnumList { get; }
        /// <summary>
        /// 新增用户
        /// </summary>
        /// <returns></returns>
        MessageModel AddUser(string name, string password, RoleEnum? roleName, ExpirationTimeEnum? expirationTimeEnum, string department);
        #endregion

        #region 部门管理
        ObservableCollection<String> DepartmentList { get; }
        /// <summary>
        /// 新增部门
        /// </summary>
        /// <returns></returns>
        MessageModel AddDepartment(string name);
        ObservableCollection<String> GetAllDepartment();
        #endregion

        #region 权限管理
        /// <summary>
        /// 更新权限
        /// </summary>
        /// <returns></returns>
        MessageModel UpdateRoleRight(RoleEnum role, List<RoleRightModel> rightList);

        /// <summary>
        /// 获取权限
        /// </summary>
        /// <param name="roleEnum"></param>
        /// <returns></returns>
        List<RoleRightModel> GetRoleRights(RoleEnum roleEnum);

        /// <summary>
        /// 获取角色清单
        /// </summary>
        /// <returns></returns>
        Dictionary<string, RoleEnum> GetRoleList();
        #endregion

        #region 其他设置
        /// <summary>
        /// 更新密码错误次数
        /// </summary>
        /// <returns></returns>
        MessageModel UpdateLockedTime(int _LockedTimeConfig);
        bool IsAdmin();
        #endregion
    }
}
